Window Remote Control

This script creates a small remote control that lets you move backwards and forwards through your history, or reload the current page for this window.



Discussion

The remote control is created as a separate window; the opener property of the new window points back to this window. The remote needs this in order to access this page's history. If no parent window is found, the remote will first attempt to back up and otherwise will close itself.

// Create and pop up a small window
function PopIt()
{
  popup = window.open("CONTROL1.HTM","popDialog",
      "height=60,width=156,scrollbars=no")
      
  // repeat for Macs
  popup = window.open("CONTROL1.HTM","popDialog",
      "height=60,width=156,scrollbars=no")

  // popup.opener points back to this window   
}

The new remote must point to a main window

if (self.opener == null) 
{
    if (self.history.length > 1)
    {
        alert('There is no main window associated with this remote. '+
              'The remote control will now back up to the previous window.')
        self.history.go(-1)
    }
    else
    {
        alert('This remote control has no main window.  '+
            'This remote will now close.')
        self.close()
    }
}
Copyright ©2000 by Charles River Media, All Rights Reserved